import 'package:boss/color_constant.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/page/reportForm/billSummary/provider/bill_summary_provider.dart';

import 'package:boss/ui/widget/split_line.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'bill_price_title.dart';
import 'bill_title_num.dart';

class BillCollectionPanel extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return DefaultTextStyle(
      style: TextStyle(
        height: 1,
        fontSize: 28.sp,
        color: Colors.white,
      ),
      child: Container(
        width: double.infinity,
        height: 380.w,
        margin: EdgeInsets.only(
          top: 30.w,
        ),
        padding: EdgeInsets.only(
          top: 30.w,
          left: 32.w,
          bottom: 53.w,
          right: 46.w,
        ),
        decoration: BoxDecoration(
          image: DecorationImage(
            image: AssetImage('assets/image/bill_bg.png'),
            fit: BoxFit.cover,
          ),
          borderRadius: BorderRadius.circular(
            14.w,
          ),
        ),
        child: Consumer<BillSummaryProvider>(
          builder: (context, billSummaryProvider, _) {
            final actualPrice = AmountUtil.price2yf(billSummaryProvider.billSummary.totalFee);
            final actuaY = actualPrice[0];
            String actuaF ='00';
            if(actualPrice.length!=1){
               actuaF = actualPrice[1];
            }
            final feePriceText = AmountUtil.price2String(billSummaryProvider.billSummary.feeAmount);

            return Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                RichText(
                  text: TextSpan(
                    text: '实收金额',
                    style: TextStyle(
                      height: 1,
                      fontSize: 28.sp,
                    ),
                    children: [
                      TextSpan(
                        text: '/元',
                        style: TextStyleConstant().white_24,
                      ),
                    ],
                  ),
                ),
                Expanded(
                  child: Container(
                    margin: EdgeInsets.only(
                      top: 50.w,
                    ),
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Expanded(
                          child: Row(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: <Widget>[
                              Container(
                                padding: EdgeInsets.only(
                                  top: ScreenUtil.instance.setWidth(7.5),
                                ),
                                margin: EdgeInsets.only(
                                  right: 5.w,
                                ),
                                child: Text(
                                  '¥',
                                  style: TextStyle(
                                    color: ColorConstant.ffda44,
                                    fontSize: 40.sp,
                                    height: 1,
                                  ),
                                ),
                              ),
                              Expanded(
                                child: RichText(
                                  overflow: TextOverflow.ellipsis,
                                  text: TextSpan(
                                    text: '$actuaY',
                                    style: TextStyle(
                                      fontSize: 80.sp,
                                      height: 1,
                                      fontFamily: 'DINAlternate-Bold',
                                    ),
                                    children: [
                                      TextSpan(
                                        text: '.$actuaF',
                                        style: TextStyle(
                                          fontSize: 32.sp,
                                          height: 1,
                                          fontFamily: 'DINAlternate-Bold',
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                        Expanded(
                          child: Row(
                            children: <Widget>[
                              BillTitleNum(
                                title: '订单数',
                                unit: '单',
                                number: '${billSummaryProvider.billSummary.orderNum}',
                                numberTextStyle: TextStyle(
                                  color: Colors.white,
                                  fontSize: 30.sp,
                                  height: 1,
                                  fontFamily: 'DINAlternate-Bold',
                                ),
                              ),
                              BillTitleNum(
                                title: '小费',
                                unit: '元',
                                number: '$feePriceText',
                                numberTextStyle: TextStyle(
                                  color: ColorConstant.fe7f76,
                                  fontSize: 30.sp,
                                  height: 1,
                                  fontFamily: 'DINAlternate-Bold',
                                ),
                              ),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
                Row(
                  children: <Widget>[
                    BillPriceTitle(
                      price: billSummaryProvider.billSummary.orderAmount,
                      title: '订单金额',
                    ),
                    SplitLine(
                      height: 60.w,
                    ),
                    BillPriceTitle(
                      price: billSummaryProvider.billSummary.receiveAmount,
                      title: '应收金额',
                    ),
                  ],
                ),
              ],
            );
          },
        ),
      ),
    );
  }
}
